<?

require(dirname(__FILE__).'/_base/BaseTaskTime.php');

class TaskTime extends BaseTaskTime{
    
    public static function model($className=__CLASS__) {
        return parent::model($className);
    }
    
    public function rules() {
        return array(
            array('task_id, user_id, time_start', 'required'),
            array('task_id, user_id, time_start, time_end, time_break', 'numerical', 'integerOnly'=>true),
            array('id, task_id, user_id, time_start, time_end, time_break, comment', 'safe', 'on'=>'search'),
        );
    }
    
    public function relations() {
        return array(
            'time_task' => array(self::BELONGS_TO, 'Task', 'task_id'),
            'time_user' => array(self::BELONGS_TO, 'TaskUser', 'user_id'),
        );
    }
    
    function timeFormat($time){
        return sprintf('%02d:%02d:%02d', $time/3600, ($time % 3600)/60, ($time % 3600) % 60);
    }
    
}
